//
//  ECMaterialTypeBigTypeHeaderView.m
//  ECERP.CRM
//
//  Created by huanggulong on 2018/11/23.
//  Copyright © 2018 升鲜宝. All rights reserved.
//

#import "ECMaterialTypeBigTypeHeaderView.h"

@implementation ECMaterialTypeBigTypeHeaderView

- (instancetype)initWithReuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithReuseIdentifier:reuseIdentifier];
    if (self) {
        [self setUI];
    }
    return self;
}

- (void)setUI{
    UILabel *label = [[UILabel alloc] init];
    label.font = [UIFont systemFontOfSize:14];
    label.textColor = @"#333333".toColor;
    [self.contentView addSubview:label];
    label.userInteractionEnabled = YES;
    [label addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapClick:)]];
    
    UIImageView *imageView = [[UIImageView alloc] init];
    imageView.image = [UIImage imageNamed:@"material_type_fold"];
    imageView.highlightedImage = [UIImage imageNamed:@"material_type_unfold"];
    [self.contentView addSubview:imageView];
    
    [label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(28);
        make.centerY.offset(0);
        make.right.offset(-8);
    }];
    
    [imageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(9);
        make.centerY.offset(0);
        make.size.sizeOffset(CGSizeMake(15, 15));
    }];
    _nameLabel = label;
    _imageView = imageView;
    
    UIButton *button = [[UIButton alloc] init];
//    UIImage *image = [UIImage imageNamed:@"add_icon"];
//    image = [image imageWithRenderingMode:(UIImageRenderingModeAlwaysTemplate)];
//    button.imageView.tintColor = @"".toColor;
    [button setImage:[UIImage imageNamed:@"material_type_add"] forState:(UIControlStateNormal)];
    [self.contentView addSubview:button];
    [button mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.offset(-2);
        make.top.and.bottom.offset(0);
        make.width.offset(44);
    }];
    _addButton = button;
    
    UIView *lineView = [[UIView alloc] init];
    lineView.backgroundColor = @"#f4f4f4".toColor;
    [self.contentView addSubview:lineView];
    [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.bottom.and.right.offset(0);
        make.height.offset(1);
    }];
}

- (void)tapClick:(id)sender{
    if ([self.delegate respondsToSelector:@selector(headerView:section:)]) {
        [self.delegate headerView:self section:self.contentView.tag];
    }
}

@end
